
const { getPath } = require('./utils')


// 这个插件是必须的！ 它的职责是将你定义过的其它规则复制并应用到 .vue 文件里相应语言的块。例如，如果你有一条匹配 /\.js$/ 的规则，那么它会应用到 .vue 文件里的 <script> 块
const VueLoaderPlugin = require('vue-loader/lib/plugin')


console.log('路径',__dirname)
console.log('路径',getPath('../index.html'))

module.exports = {
    entry: getPath('../src/main.js'),
    output: {
        filename: '[name].[hash].js',
        path: getPath('../dist'),
        publicPath: "/"
    },
    plugins: [
        new VueLoaderPlugin(),

    ],
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader',
                options: {
                    hotReload: true // 关闭热重载
                }
            },
            {
                test: /\.(png|svg|jpg|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit:8192,
                            outputPath:'static/'
                        }
                    }
                ]
            },
            {
                test: /\.(woff|woff2|eot|ttf|otf)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            name:'[name].[hash].[ext]',
                            outputPath:'static/'
                        }
                    }
                ]
            }
        ]
    },
    resolve: {
        extensions: ['.js', '.vue', '.json'],
        alias: {
            'vue$': 'vue/dist/vue.esm.js',
            '@':getPath('../src')
        }
    }
}